package com.imooc.controller;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.jms.Queue;
import java.util.UUID;

@ApiIgnore
@RestController
public class HelloController {
    final static Logger logger = LoggerFactory.getLogger(HelloController.class);

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Queue queue;

    @GetMapping("/hello")
    public Object hello() {
        logger.info("info = info");
        logger.warn("warn = warn");
        logger.error("error = error");
        return "hello world";
    }


    @GetMapping("/sendmq")
    public Object sendMq() {
        jmsMessagingTemplate.convertAndSend(queue, "发送一条消息：" + UUID.randomUUID().toString());
        return "ok";
    }


}
